#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    QDateTime oldtime = ui->dateTimeEdit_old->dateTime();
    QDateTime newtime = ui->dateTimeEdit_new->dateTime();

    int days = oldtime.daysTo(newtime);
    int hours = (oldtime.secsTo(newtime) / 3600) % 24;
    if(oldtime.time() > newtime.time())
    {
        days--;
    }

    QString text = QString("它们之间的时间为：")+QString::number(days)+QString("天零")
            +QString::number(hours)+QString("小时");
    ui->label->setText(text);
}
